package com.jl.smartcard.ui;

import org.eclipse.jface.action.GroupMarker;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.ICoolBarManager;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.action.ToolBarContributionItem;
import org.eclipse.jface.action.ToolBarManager;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;

public class ApplicationActionBarAdvisor extends ActionBarAdvisor {

	private IAction help_about = null;
	private IAction help_dynamic = null;
	private IAction help_search = null;
	
	private IAction undo;
	private IAction redo;
	
	private IAction copy = null;
	private IAction cut = null;
	private IAction paste = null;
	private IAction delete = null;
	private IAction selectAll = null;
	
	private IAction newWindow = null;
	private IAction preferance = null;
	private IAction resetPerspactive = null;
	
	private IAction _new = null;
	//private IAction newEditor = null;
	private IAction newWiser = null;
	private IAction save = null;
	private IAction saveAll = null;
	private IAction saveAs = null;
	private IAction close = null;
	private IAction closeAll = null;
	//private IAction closeAllSaved = null;
	private IAction quit = null;
	private IAction print = null;
	private IAction properties = null;
	private IAction refresh = null;
	private IAction export = null;
	private IAction importAction = null;
	
	
	
	
    public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) {
        super(configurer);
    }

    @Override
	protected void makeActions(IWorkbenchWindow window) {
    	//file
    	_new = ActionFactory.NEW.create(window); 
    	register(_new);
    	//newEditor = ActionFactory.NEW_EDITOR.create(window); 	
    	newWiser = ActionFactory.NEW_WIZARD_DROP_DOWN.create(window); 	
    	register(newWiser);
    	
    	export = ActionFactory.EXPORT.create(window);
    	register(export);
    	importAction = ActionFactory.IMPORT.create(window);
    	register(importAction);
    	
    	save = ActionFactory.SAVE.create(window);
    	register(save);
    	saveAll = ActionFactory.SAVE_ALL.create(window);
    	register(saveAll);
    	saveAs = ActionFactory.SAVE_AS.create(window);
    	register(saveAs);
    	close = ActionFactory.CLOSE.create(window);
    	register(close);
    	closeAll = ActionFactory.CLOSE_ALL.create(window);
    	register(closeAll);
    	print = ActionFactory.PRINT.create(window);
    	register(print);
    	properties = ActionFactory.PROPERTIES.create(window);
    	register(properties);
    	
    	refresh = ActionFactory.REFRESH.create(window);
    	register(refresh);
    	
    	//closeAllSaved = ActionFactory.CLOSE_ALL_SAVED.create(window);
    	//register(closeAllSaved);
    	quit = ActionFactory.QUIT.create(window);
    	register(quit);
    	//edit
    	undo = ActionFactory.UNDO.create(window);
    	register(undo);
    	redo = ActionFactory.REDO.create(window);
    	register(redo);
    	copy = ActionFactory.COPY.create(window);
    	register(copy);
    	cut = ActionFactory.CUT.create(window);
    	register(cut);
    	paste = ActionFactory.PASTE.create(window);
    	register(paste);
    	delete = ActionFactory.DELETE.create(window);
    	register(delete);
    	selectAll = ActionFactory.SELECT_ALL.create(window);
    	register(selectAll);
    	//window
    	newWindow = ActionFactory.OPEN_NEW_WINDOW.create(window);
    	register(newWindow);
    	preferance = ActionFactory.PREFERENCES.create(window);
    	register(preferance);
    	resetPerspactive = ActionFactory.RESET_PERSPECTIVE.create(window);
    	register(resetPerspactive);
    	//help
    	help_about = ActionFactory.ABOUT.create(window);
    	register(help_about);
    	
    	help_dynamic = ActionFactory.DYNAMIC_HELP.create(window);
    	register(help_dynamic);
    	
    	help_search = ActionFactory.HELP_SEARCH.create(window);
    	register(help_search);
    	
    }

    @Override
	protected void fillMenuBar(IMenuManager menuBar) {
    	//file
    	MenuManager file = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
    	file.add(_new);
    	file.add(newWiser);
    	file.add(new Separator());
    	file.add(save);
    	file.add(saveAll);
    	file.add(saveAs);
    	file.add(new Separator());
    	file.add(close);
    	file.add(closeAll);
    	//file.add(closeAllSaved);
    	file.add(new Separator());
    	file.add(refresh);
    	file.add(new Separator());
    	file.add(print);
    	file.add(new Separator());
    	file.add(properties);
    	file.add(new Separator());
    	file.add(importAction);
    	file.add(export);
    	file.add(new Separator());
    	file.add(quit);
    	menuBar.add(file);
    	
    	//edit
    	MenuManager edit = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT);
    	edit.add(undo);
    	edit.add(redo);
    	edit.add(new Separator());
    	edit.add(copy);
    	edit.add(cut);
    	edit.add(paste);
    	edit.add(new Separator());
    	edit.add(delete);
    	edit.add(selectAll);
    	edit.add(new Separator());
    	edit.add( new GroupMarker( IWorkbenchActionConstants.FIND_EXT ) );
    	menuBar.add(edit);
    	
    	//search
    	MenuManager search = new MenuManager("&Search", "org.eclipse.search.menu");
    	menuBar.add(search);
    	
    	//project
    	MenuManager project = new MenuManager("&Project", IWorkbenchActionConstants.M_PROJECT);
    	menuBar.add(project);
    	
    	//run
    	MenuManager run = new MenuManager("&Run", "org.eclipse.ui.run");
    	menuBar.add(run);
    	
    	//java card
    	MenuManager javacard = new MenuManager("&JavaCard", "org.eclipsejcde.jctools.menu");
    	menuBar.add(javacard);
    	
    	//tools
    	MenuManager tools = new MenuManager("&Tools", "ToolsMenu");
    	menuBar.add(tools);
    	
    	
    	//window
    	MenuManager window = new MenuManager("&Window", IWorkbenchActionConstants.M_WINDOW);
    	window.add(newWindow);
    	window.add(resetPerspactive);
    	window.add(new Separator());
    	window.add(preferance);
    	menuBar.add(window);
    	//help
		MenuManager help = new MenuManager("&Help",
				IWorkbenchActionConstants.M_HELP);
		
		help.add(new Separator());
		help.add(help_dynamic);
		help.add(help_search);
		help.add(new Separator());
		help.add(help_about);
		menuBar.add(help);
		
		//menuBar.remove("additions");
    }
    
    @Override
    protected void fillCoolBar(ICoolBarManager coolBar) {
    	//file
    	ToolBarManager file = new ToolBarManager();
    	file.add(_new);
    	file.add(save);
    	file.add(saveAll);
    	coolBar.add(new ToolBarContributionItem(file,"coolBar.file"));
    }
    
    
}
